import React from "react";
import Axios from "../../../../axios/axiosUnit";
import CompItem from "../compItem/CompItem";
import "./ComponentList.css";

export default class ComponentList extends React.Component {
    constructor(props) {
        super(props)
    }
    state = {
        compList: []
    }

    componentDidMount() {
        let that = this;
        Axios.get({
            url: "./ajax/componentList.json",
            success(data) {
                that.setState({
                    compList: data.data
                });
            },
            error(e) {
                console.error(e);
            }
        })
    }
    render() {
        return (
            this.state.compList.map((item, index) => {
                return (
                    <React.Fragment key={item.id}>
                        <CompItem option={{ item }}></CompItem>
                    </React.Fragment>
                )
            })
        )
    }
}